package com.example.myapplication01.jetpack.room;

import android.content.Context;

import androidx.lifecycle.LiveData;

import java.util.List;
import java.util.concurrent.CompletableFuture;

public class UserRepository {

    private final LiveData<List<User>> liveUserListData;
    private final UserDao userDao;

    public UserRepository(Context context) {
        userDao = UserDatabase.getInstance(context).getUserDao();
        liveUserListData = userDao.selectAll();
    }

    public LiveData<List<User>> getLiveUserListData() {
        return liveUserListData;
    }

    public void insert(User... users) {
        CompletableFuture.runAsync(() -> userDao.insert(users));
    }

}
